//
//  FriendCollectionCell.m
//  TipsProject
//
//  Created by Suny on 15/6/15.
//  Copyright (c) 2015年 Suny. All rights reserved.
//

#import "FriendCollectionCell.h"
#import "UIImageView+WebCache.h"

@interface FriendCollectionCell ()
@property (strong, nonatomic) UIImageView *headImageView;
@property (strong, nonatomic) UILabel *nameLabel;
@end
@implementation FriendCollectionCell


- (UIImageView *)headImageView
{
    if (!_headImageView)
    {
        _headImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        _headImageView.clipsToBounds = YES;
        _headImageView.contentMode = UIViewContentModeScaleAspectFill;
        _headImageView.layer.borderWidth = 0;
        [self addSubview:_headImageView];
    }
    return _headImageView;

}

- (UILabel *)nameLabel
{
    if (!_nameLabel)
    {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
		_nameLabel.backgroundColor = [UIColor clearColor];
		_nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.numberOfLines = 0;
        [self addSubview:_nameLabel];
    }
    return _nameLabel;

}

- (void)setDisplayInfo:(FriendFloawDisplayInfo *)displayInfo
{
	_displayInfo = displayInfo;
	self.nameLabel.text = displayInfo.userInfo.nickName;
	[self setNeedsDisplay];
	[self setNeedsLayout];
}

- (void)layoutSubviews
{
    [super layoutSubviews];

    self.headImageView.frame = CGRectMake(10, 10, self.width - 2*10, self.width - 2*10);
	self.headImageView.layer.cornerRadius = self.headImageView.width/2.0;
    [self.headImageView setQNImageWithURL:[NSURL URLWithString:self.displayInfo.userInfo.headPhoto]
                          placeholderImage:[UIImage imageNamed:kDefaultHeaderImage]];

    self.nameLabel.frame = CGRectMake(10, self.headImageView.bottom + 5, self.width - 2*10, 30);

}

@end
